﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace XNAGame_Lab1
{
    public abstract class VisibleGame : GameEntity
    {
        private List<MySprites2D> _sprites;

        protected List<MySprites2D> Sprites
        {
            get { return _sprites; }
            set { _sprites = value; }
        }
        private int _nSprites;

        protected int nSprites
        {
            get { return _nSprites; }
            set { _nSprites = value; }
        }

        protected Vector2 _TopLeft;

        public Vector2 TopLeft
        {
            get { return _TopLeft; }
            set { _TopLeft = value;
            for (int i = 0; i < nSprites; i++)
                Sprites[i].Position = TopLeft;
            }
        }
        protected Vector2 _Size;

        public Vector2 Size
        {
            get { return _Size; }
            set { _Size = value; }
        }
        override public void Update(GameTime gameTime)
        {
            for (int i = 0; i < nSprites; i++)
                Sprites[i].Update(gameTime);
        }
        override public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < nSprites; i++)
                Sprites[i].Draw(gameTime,spriteBatch);
            
        }
        virtual public bool isClicked(Vector2 point)
        {
            if (point.X >= TopLeft.X && point.X < TopLeft.X + Size.X &&
                point.Y >= TopLeft.Y && point.Y < TopLeft.Y + Size.Y)
                return true;
            return false;
        }
    }
}
